package com.ssy.lingxi.order.model.dto;

import com.ssy.lingxi.order.model.constant.OrderPromotionTypeEnum;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 订单商品SkuId Dto
 * @author 万宁
 * @version 2.0.0
 * @date 2021-11-01
 */
public class ProductSkuDTO implements Serializable {
    private static final long serialVersionUID = 3206398035465213440L;

    public ProductSkuDTO(Long buyerMemberId, Long buyerRoleId, Long vendorMemberId, Long vendorRoleId, Long skuId, BigDecimal quantity, Integer promotionType, Integer groupNo, Long parentSkuId) {
        this.buyerMemberId = buyerMemberId;
        this.buyerRoleId = buyerRoleId;
        this.vendorMemberId = vendorMemberId;
        this.vendorRoleId = vendorRoleId;
        this.skuId = skuId;
        this.quantity = quantity;
        this.promotionType = promotionType;
        this.groupNo = promotionType.equals(OrderPromotionTypeEnum.PRIMARY_OF_SET.getCode()) ? groupNo : 0;
        this.parentSkuId = promotionType.equals(OrderPromotionTypeEnum.EXCHANGED.getCode()) ? parentSkuId : 0;
    }

    /**
     * 采购会员Id
     */
    private Long buyerMemberId;

    /**
     * 采购会员角色Id
     */
    private Long buyerRoleId;

    /**
     * 供应会员Id
     */
    private Long vendorMemberId;

    /**
     * 供应会员角色Id
     */
    private Long vendorRoleId;

    /**
     * 商品SkuId
     */
    private Long skuId;

    /**
     * 购买数量
     */
    private BigDecimal quantity;

    /**
     * 营销活动类型，定义在 OrderPromotionTypeEnum 中
     */
    private Integer promotionType;

    /**
     * 套餐主商品，关联的套餐号
     */
    private Integer groupNo;

    /**
     * 被换购商品，关联的商品SkuId
     */
    private Long parentSkuId;

    public Long getBuyerMemberId() {
        return buyerMemberId;
    }

    public void setBuyerMemberId(Long buyerMemberId) {
        this.buyerMemberId = buyerMemberId;
    }

    public Long getBuyerRoleId() {
        return buyerRoleId;
    }

    public void setBuyerRoleId(Long buyerRoleId) {
        this.buyerRoleId = buyerRoleId;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public BigDecimal getQuantity() {
        return quantity;
    }

    public void setQuantity(BigDecimal quantity) {
        this.quantity = quantity;
    }

    public Integer getPromotionType() {
        return promotionType;
    }

    public void setPromotionType(Integer promotionType) {
        this.promotionType = promotionType;
    }

    public Integer getGroupNo() {
        return groupNo;
    }

    public void setGroupNo(Integer groupNo) {
        this.groupNo = groupNo;
    }

    public Long getParentSkuId() {
        return parentSkuId;
    }

    public void setParentSkuId(Long parentSkuId) {
        this.parentSkuId = parentSkuId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        ProductSkuDTO that = (ProductSkuDTO) o;
        return Objects.equals(skuId, that.skuId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(skuId);
    }
}
